using System;
using System.Collections.ObjectModel;
using System.Linq;
using XenoGears.ComponentModel;
using XenoGears.Functional;
using XenoGears.Reflection;
using XenoGears.Reflection.Attributes.Snippets;

namespace Jink.Core.Converters.Context
{
    internal static class EventsRegistry
    {
        public static ReadOnlyCollection<Action<ConversionContext>> OnInit
        {
            get
            {
                var snippets = SnippetRegistry.For<OnConversionContextInitAttribute>();
                return snippets.Select(s => s.Code.BindDelegate<Action<ConversionContext>>()).ToReadOnly();
            }
        }

        public static ReadOnlyCollection<Action<ConversionContext, ListChangeEventArgs>> OnChanged
        {
            get
            {
                var snippets = SnippetRegistry.For<OnConversionContextChangedAttribute>();
                return snippets.Select(s => s.Code.BindDelegate<Action<ConversionContext, ListChangeEventArgs>>()).ToReadOnly();
            }
        }
    }
}